package com.example.tank.entity;

import java.awt.*;

public class Bullet {
    private int x;
    private int y;
    private int speed = 8;
    private int direction; // 0-up, 1-right, 2-down, 3-left
    private static final int SIZE = 6;
    
    public Bullet(int x, int y, int direction) {
        this.x = x;
        this.y = y;
        this.direction = direction;
    }
    
    public void update() {
        switch (direction) {
            case 0: // up
                y -= speed;
                break;
            case 1: // right
                x += speed;
                break;
            case 2: // down
                y += speed;
                break;
            case 3: // left
                x -= speed;
                break;
        }
    }
    
    public void draw(Graphics g) {
        g.setColor(Color.YELLOW);
        g.fillOval(x, y, SIZE, SIZE);
    }
    
    public Rectangle getBounds() {
        return new Rectangle(x, y, SIZE, SIZE);
    }
    
    public boolean isOffScreen(int screenWidth, int screenHeight) {
        return x < 0 || x > screenWidth || y < 0 || y > screenHeight;
    }
}